<template>
  <div class="app-container">
    <el-dialog
      title="选择设备"
      :visible.sync="dialogTableVisible"
      :close-on-click-modal="false"
      :before-close="close"
      width="1000px">
    <el-form :model="selectForm" ref="queryForm" :inline="true">
      <el-form-item label="设备编号：">
        <el-input  v-model="selectForm.deviceCode" placeholder="请输入设备编号" clearable/>
      </el-form-item>
      <el-form-item label="设备名称：">
        <el-input  v-model="selectForm.deviceName" placeholder="请输入设备名称" clearable/>
      </el-form-item>
      <el-form-item label="类别：" >
        <treeSelect v-show="true"   @deviceType="deviceTypeChange" type="deviceType"></treeSelect>
      </el-form-item>
      <el-form-item label="设备状态：">
        <el-select v-model="selectForm.status" placeholder="请选择">
          <el-option
            v-for="item in deviceStatus"
            :key="item.label"
            :label="item.label"
            :value="item.label">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="设备品牌：">
        <el-input  v-model="selectForm.brand" placeholder="请输入设备品牌" clearable/>
      </el-form-item>
      <el-form-item label="规格型号：" >
        <el-input  v-model="selectForm.specificationsModels" placeholder="请输入规格型号" clearable/>
      </el-form-item>
      <el-form-item>
        <el-button size="mini" type="primary" icon="el-icon-search" @click="getList">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="list" border  @selection-change="currentChange">
      <el-table-column type="selection" width="55" />
      <el-table-column align="center" type="index" label="序号" width="55"/>
      <el-table-column align="center" label="设备编号" prop="deviceCode"/>
      <el-table-column align="center" label="设备名称" prop="deviceName"/>
      <el-table-column align="center" label="类别" prop="deviceTypeName"/>
      <el-table-column align="center" label="品牌" prop="deviceBrandName"/>
      <el-table-column align="center" label="规格型号" prop="deviceModel"/>
      <el-table-column align="center" label="状态" prop="deviceStatusName"></el-table-column>
<!--      <el-table-column align="center" label="购置金额" prop="buyMoney"/>-->
    </el-table>
    <pagination
      :total="total"
      :page.sync="selectForm.pageNum"
      :limit.sync="selectForm.pageSize"
      @pagination="getList"
    />
    <span slot="footer" class="dialog-footer">
      <el-button size="mini" @click="$emit('selectChange')">取消</el-button>
      <!-- <el-button size="mini" @click="submit">确定</el-button> -->
      <el-button type="primary"  size="mini" @click="submit">确 定</el-button>
    </span>
    </el-dialog>
  </div>
</template>

<script>
  import request from '@/utils/request'
  import department from "./department";
  import treeSelect from '../../equipmentGL/equipmentTZ/treeSelect'
  export default {
    name: "addDialog.vue",
    components:{
      department,
      treeSelect
    },
    data() {
      return {
        dialogTableVisible:true,
        loading: false,//加载
        selectForm: {
          deviceCode: '',//设备编号
          deviceName: '',//设备名称
          category: '',//
          status: '',//
          brand:'',
          specificationsModels:'',
          pageNum: 1,
          pageSize: 10,
        },//查询条件
        list: [],//数据
        total: 0,
        selectDate: '',//时间
        deviceStatus:[{
          value:'',
          label:'保养',
        },{
          value:'',
          label:'闲置',
        },{
          value:'',
          label:'在用',
        },{
          value:'',
          label:'预转固',
        },{
          value:'',
          label:'故障',
        },{
          value:'',
          label:'正常',
        }],
        selectData:'',
      }
    },
    created() {
      this.getList()
    },
    methods: {
      //类别监听
      deviceTypeChange:function(data){

      },
      getList() {
        this.loading = true;
        request({
          url: '/device-receive-api/device',
          method: 'get',
          params:this.selectForm
        }).then(response => {
          this.loading = false;
          this.list = response.rows
          this.total = response.total
        });
      },
      close(){
        this.$emit('selectChange')
      },
     currentChange(val){
        this.selectData=val
      },
      submit(){
        if(this.selectData){
          this.$emit('selectChange',this.selectData)
        }
      }
    }
  }
</script>

<style scoped>
  .bule {
    color: #2196F3;
    cursor: pointer
  }
  .status{
    color: white;
    width: 54px;
    height: 22px;
    display: inline-block;
    text-align: center;
  }
  .green{
    background: #78BF34;
  }
  .purple{
    background:#9E71DC
  }
  .red{
    background: red;
  }
</style>
